package com.ruoyi.lock.service.impl;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.lock.domain.AFaultReport;
import com.ruoyi.lock.mapper.AFaultReportMapper;
import com.ruoyi.lock.service.IAFaultReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 故障上报Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-04-16
 */
@Service
public class AFaultReportServiceImpl implements IAFaultReportService 
{
    @Autowired
    private AFaultReportMapper aFaultReportMapper;

    /**
     * 查询故障上报
     * 
     * @param id 故障上报主键
     * @return 故障上报
     */
    @Override
    public AFaultReport selectAFaultReportById(Long id)
    {
        return aFaultReportMapper.selectAFaultReportById(id);
    }

    /**
     * 查询故障上报列表
     * 
     * @param aFaultReport 故障上报
     * @return 故障上报
     */
    @Override
    public List<AFaultReport> selectAFaultReportList(AFaultReport aFaultReport)
    {
        return aFaultReportMapper.selectAFaultReportList(aFaultReport);
    }

    @Override
    @DataScope(deptAlias = "d")
    public List<AFaultReport> selectAFaultReportList1(AFaultReport aFaultReport)
    {
        return aFaultReportMapper.selectAFaultReportList1(aFaultReport);
    }

    /**
     * 新增故障上报
     * 
     * @param aFaultReport 故障上报
     * @return 结果
     */
    @Override
    public int insertAFaultReport(AFaultReport aFaultReport)
    {
        aFaultReport.setCreateTime(DateUtils.getNowDate());
        aFaultReport.setCreateBy(SecurityUtils.getUsername());
        aFaultReport.setUserId(SecurityUtils.getUserId());
        return aFaultReportMapper.insertAFaultReport(aFaultReport);
    }


    @Override
    public int listCount(AFaultReport aFaultReport) {
        return aFaultReportMapper.listCount(aFaultReport);
    }

    /**
     * 修改故障上报
     * 
     * @param aFaultReport 故障上报
     * @return 结果
     */
    @Override
    public int updateAFaultReport(AFaultReport aFaultReport)
    {
        return aFaultReportMapper.updateAFaultReport(aFaultReport);
    }

    /**
     * 批量删除故障上报
     * 
     * @param ids 需要删除的故障上报主键
     * @return 结果
     */
    @Override
    public int deleteAFaultReportByIds(Long[] ids)
    {
        return aFaultReportMapper.deleteAFaultReportByIds(ids);
    }

    /**
     * 删除故障上报信息
     * 
     * @param id 故障上报主键
     * @return 结果
     */
    @Override
    public int deleteAFaultReportById(Long id)
    {
        return aFaultReportMapper.deleteAFaultReportById(id);
    }
}
